package com.ruoyi.web.controller.xcx;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.ATeamInfo;
import com.ruoyi.system.domain.vo.XcxATeamInfoVO;
import com.ruoyi.system.domain.vo.XcxOperTeamInfoVO;
import com.ruoyi.system.service.IATeamInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 团队Controller
 *
 * @author ruoyi
 * @date 2024-05-16
 */
@RestController
@RequestMapping("/xcx/aTeamInfo")
public class XcxATeamInfo extends BaseController {

    @Autowired
    private IATeamInfoService aTeamInfoService;


    /**
     * --查询团队成员列表
     * --查询审核团队成员列表  "reviewStatus":0代表申请中 1代表成功  2代表失败
     */
    @GetMapping("/list")
    public TableDataInfo list(ATeamInfo aTeamInfo)
    {
        startPage();
        List<XcxATeamInfoVO> list = aTeamInfoService.selectATeamInfoXcxList(aTeamInfo);
        return getDataTable(list);
    }

    /**
     * --申请加入团队
     */
    @PostMapping("/teamJoin")
    public AjaxResult teamJoin(@RequestBody XcxOperTeamInfoVO xcxOperTeamInfoVO)
    {
        return toAjax(aTeamInfoService.teamJoin(xcxOperTeamInfoVO));
    }

    /**
     * -- 1同意
     */
    @PostMapping("/agreeTeam")
    public AjaxResult agreeTeam(@RequestBody XcxOperTeamInfoVO xcxOperTeamInfoVO)
    {
        return toAjax(aTeamInfoService.agreeTeam(xcxOperTeamInfoVO));
    }


    /**
     * --2驳回
     */
    @PostMapping("/rejectTeam")
    public AjaxResult rejectTeam(@RequestBody XcxOperTeamInfoVO xcxOperTeamInfoVO)
    {
        return toAjax(aTeamInfoService.rejectTeam(xcxOperTeamInfoVO));
    }

    /**
     * -- 3退出团队操作
     */
    @PostMapping("/quitTeam")
    public AjaxResult quitTeam()
    {
        return toAjax(aTeamInfoService.quitTeam());
    }

    /**
     * -- 4删除团队成员操作
     */
    @PostMapping("/delTeamInfo")
    public AjaxResult delTeamInfo(@RequestBody ATeamInfo aTeamInfo) {
        Long userId = aTeamInfo.getUserId();
        Long uId = aTeamInfo.getUserId();
        if (userId == null || uId == null) {
            return AjaxResult.error("参数错误");
        }
        return toAjax(aTeamInfoService.delTeamInfo(aTeamInfo));
    }
}
